package com.procurement.bidding.controller;

import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.procurement.bidding.domain.PcmEvaluationCriteria;
import com.procurement.bidding.service.IPcmEvaluationCriteriaService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 评标条例Controller
 * 
 * @author feng
 * @date 2023-11-22
 */
@RestController
@RequestMapping("/criteria")
public class PcmEvaluationCriteriaController extends BaseController
{
    @Autowired
    private IPcmEvaluationCriteriaService pcmEvaluationCriteriaService;

    /**
     * 查询评标条例列表
     */
//    @RequiresPermissions("bidding:criteria:list")
    @GetMapping("/list")
    public TableDataInfo list(PcmEvaluationCriteria pcmEvaluationCriteria)
    {
        startPage();
        List<PcmEvaluationCriteria> list = pcmEvaluationCriteriaService.selectPcmEvaluationCriteriaList(pcmEvaluationCriteria);
        return getDataTable(list);
    }

    /**
     * 导出评标条例列表
     */
//    @RequiresPermissions("bidding:criteria:export")
    @Log(title = "评标条例", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PcmEvaluationCriteria pcmEvaluationCriteria)
    {
        List<PcmEvaluationCriteria> list = pcmEvaluationCriteriaService.selectPcmEvaluationCriteriaList(pcmEvaluationCriteria);
        ExcelUtil<PcmEvaluationCriteria> util = new ExcelUtil<PcmEvaluationCriteria>(PcmEvaluationCriteria.class);
        util.exportExcel(response, list, "评标条例数据");
    }

    /**
     * 获取评标条例详细信息
     */
//    @RequiresPermissions("bidding:criteria:query")
    @GetMapping(value = "/{evaluationCriteriaId}")
    public AjaxResult getInfo(@PathVariable("evaluationCriteriaId") Long evaluationCriteriaId)
    {
        return success(pcmEvaluationCriteriaService.selectPcmEvaluationCriteriaByEvaluationCriteriaId(evaluationCriteriaId));
    }

    /**
     * 新增评标条例
     */
//    @RequiresPermissions("bidding:criteria:add")
    @Log(title = "评标条例", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PcmEvaluationCriteria pcmEvaluationCriteria)
    {
        pcmEvaluationCriteria.setSubmitData(new Date());
        pcmEvaluationCriteria.setUpdateData(new Date());
        return toAjax(pcmEvaluationCriteriaService.insertPcmEvaluationCriteria(pcmEvaluationCriteria));
    }

    /**
     * 修改评标条例
     */
//    @RequiresPermissions("bidding:criteria:edit")
    @Log(title = "评标条例", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PcmEvaluationCriteria pcmEvaluationCriteria)
    {
        pcmEvaluationCriteria.setUpdateData(new Date());
        System.out.println(pcmEvaluationCriteria);
        return toAjax(pcmEvaluationCriteriaService.updatePcmEvaluationCriteria(pcmEvaluationCriteria));
    }

    /**
     * 删除评标条例
     */
//    @RequiresPermissions("bidding:criteria:remove")
    @Log(title = "评标条例", businessType = BusinessType.DELETE)
	@DeleteMapping("/{evaluationCriteriaIds}")
    public AjaxResult remove(@PathVariable Long[] evaluationCriteriaIds)
    {
        return toAjax(pcmEvaluationCriteriaService.deletePcmEvaluationCriteriaByEvaluationCriteriaIds(evaluationCriteriaIds));
    }
}
